import Vue from 'vue'
import axios from 'axios'
import VueAxios from 'vue-axios'
import {Url, Error} from 'common/js/config'

Vue.use(VueAxios, axios)

// 登录获取用户信息
export function getUserLogin(token) {
  return new Promise((resolve, reject) => {
    axios.post(`${Url}/accesstoken`, {accesstoken: token})
      .then((response) => {
        resolve(response.data)
      })
      .catch((error) => {
        if (typeof error.response.data === 'object') {
          resolve(error.response.data)
        } else {
          resolve(Error)
        }
      })
  })
}
